package chapter13;

public class TestGeometricObject {
  /** Main method */
  public static void main(String[] args) {
    // Declare and initialize two geometric objects
    GeometricObject geoObject1 = new Circle(5);
    GeometricObject geoObject2 = new Rectangle(5, 3);
    GeometricObject geoObject3 = new Square(6);

    System.out.println("The three objects have the same area? " +
      equalArea(geoObject1, geoObject2,geoObject3));

    // Display circle
    displayGeometricObject(geoObject1);

    // Display rectangle
    displayGeometricObject(geoObject2);
    // Display Square
    displayGeometricObject(geoObject3);
    // 比较面积
    Contains_Area(geoObject1,geoObject2,geoObject3);
    // 比较周长
    Contains_Perimeter(geoObject1,geoObject2,geoObject3);

  }

  /** A method for comparing the areas of two geometric objects */
  public static boolean equalArea(GeometricObject object1,
      GeometricObject object2,GeometricObject object3) {
    return object1.getArea() == object2.getArea();
  }

  /** A method for displaying a geometric object */
  public static void displayGeometricObject(GeometricObject object) {
    System.out.println();
    System.out.println("The area is " + object.getArea());
    System.out.println("The perimeter is " + object.getPerimeter());}

    public static void Contains_Area(GeometricObject object1,GeometricObject object2,GeometricObject object3){
      System.out.println("The largest of the three drawings is：");
      double max1 = 0;
      if (object1.getArea()>object2.getArea()){
        max1 = object1.getArea();
      }else {
        max1 = object2.getArea();
      }
      if (max1>object3.getArea()){
        max1 = max1;
      }else {
        max1 = object3.getArea();
      }
      System.out.println(max1);
    }
    public static void Contains_Perimeter(GeometricObject object1,GeometricObject object2,GeometricObject object3){
      double min = 0;
      System.out.println("The smallest of the three figures in perimeter is：");
      if (object1.getPerimeter()<object2.getPerimeter()){
        min = object1.getPerimeter();
      }else {
        min = object2.getPerimeter();
      }
      if (min>object3.getPerimeter()){
        min = min;
      }else {
        min = object3.getPerimeter();
      }
      System.out.println(min);
    }
  }